<template>
<div>
    <el-table  :data="
                tenantsData.filter(
                    (data) =>
                        !search ||
                        data.name
                            .toLowerCase()
                            .includes(search.toLowerCase())
                )
            " style="width: 100%" height="80vh">
        <el-table-column fixed type=index label="编号" width=150px>
        </el-table-column>
        <el-table-column  prop="account" label="账号" >
        </el-table-column>
        <el-table-column prop="name" label="姓名" >
        </el-table-column>
        <el-table-column prop="IDCard" label="身份证号" >
        </el-table-column>
        <el-table-column prop="phone" label="联系方式" >
        </el-table-column>
        <el-table-column label="状态"  >
             <template slot-scope="scope">
                 <div v-if="scope.row.state!=1&&scope.row.state!=3">
            <el-tag type="danger" v-if='scope.row.state==4'>身份认证已拒绝</el-tag>
            <el-tag type="success" v-else>身份认证已通过</el-tag>
            </div>
             <div v-else>
            <el-tag type="danger" v-if='scope.row.state==3'>身份认证审核中</el-tag>
            <el-tag type="success" v-else>身份认证未认证</el-tag>
            </div>
            </template>
        </el-table-column>
        <el-table-column prop="credits" label="信用值" > </el-table-column>
         <el-table-column align="right">
                <template slot="header" slot-scope="scope">
                    <el-input
                        v-model="search"
                        size="mini"
                        placeholder="请输入账号关键字"
                    />
                </template>
            </el-table-column>
    </el-table>
     <!-- 分页 -->
        <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="getData.currentpage"
      :page-sizes="[5, 7, 10, 15]"
      :page-size="getData.pagesize-0"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total-0">
    </el-pagination>
    </div>
</template>

<script>
import {createNamespacedHelpers} from 'vuex';
const {mapState,mapActions,mapMutations} = createNamespacedHelpers('tenants')
export default {
    data() {
        return {
             getData:{
            currentpage:1,
            pagesize:5
        },
        search:''
        };
    },
    mounted(){
        this.getTenants(this.getData)
    },
    computed:{
        ...mapState(['tenantsData','total']),
        // nowData(){
        //     return this.tenantsData.filter(elem=>elem.state!=1&&elem.state!=3)
        // },
        // nowTotal(){
        //     return this.tenantsData.filter(elem=>elem.state!=1&&elem.state!=3).length
        // }
    },
    methods:{
        ...mapActions(['getTenants']),
         handleSizeChange(val) {
        this.getData.pagesize=val
        console.log(this.getData);
        this.getTenants(this.getData);
      },
      handleCurrentChange(val) {
        this.getData.currentpage=val
        this.getTenants(this.getData);
      },
    }
    
};
</script>

<style>
.el-table{
    text-align: center;
}
</style>